import Vue from 'vue'
import VueRouter from 'vue-router'
// import Home from '../views/Home.vue'

Vue.use(VueRouter)

const routes = [
  {
    path: '/',
    // 重定向 路由路径
    redirect: '/login'
  },
  {
    path: '/login',
    // 路由懒加载：当前路由匹配 /login 以后，才去加载 login 里的js 等资源
    component: () => import('@/views/Login')
  },

  {
    path: '/layout',
    component: () => import('@/views/Layout'),
    redirect: '/layout/home',
    children: [
      {
        path: 'home',
        component: () => import('@/views/Home')
      },
      {
        path: 'user',
        component: () => import('@/views/User')
      }
    ]

  },
  {
    path: '/search',
    component: () => import('@/views/Search')
  },
  {
    path: '/search/:keywords', // 搜索结果页 ：参数名--> 需要路径上传递具体值
    component: () => import('@/views/SearchResult')
  },
  {
    path: '/article_detail', // 文章详情页
    component: () => import('@/views/ArticleDetail')
  },
  {
    path: '/user_edit', // 用户-个人信息-编辑页面
    component: () => import('@/views/User/UserEdit')
  }
]

const router = new VueRouter({
  routes
})

export default router
